Carbon


ThreadEntryProcPtr

Header: Threads.h Carbon status: Supported

Defines a pointer to a thread entry callback function. Your thread entry callback function provides an entry point to a thread that you create in your application.

typedef voidPtr(* ThreadEntryProcPtr) (
    void *threadParam
);

You would declare your function like this if you were to name it MyThreadEntryCallback:

voidPtr MyThreadEntryCallback (
    void *threadParam
);
threadParam

A pointer to a void data structure passed to this function by the NewThread function.

function result

Δ

DISCUSSION

When you create or allocate a new thread with the NewThread function, you pass the name of this entry function. You also pass a parameter that the Thread Manager passes on to the MyThreadEntryProc function. You can use this parameter to pass thread-specific information to the newly created or allocated thread. For example, you could pass something like A5 information or the address of a window to update. Or you could use this parameter to specify local storage for a thread that other threads could access.

When the code in a thread finishes executing, the Thread Manager automatically calls the DisposeThread function to dispose of the thread. The MyThreadEntryProc function passes its function result to DisposeThread. The DisposeThread function passes this result back to the NewThread function that called MyThreadEntryProc to begin with.

This mechanism allows you to spawn a thread that does some work and then continue with your original thread. When the spawned thread is finished doing its workófor example a calculationóit returns the result to the original thread.

AVAILABILITY

Supported in Carbon.


© 2000 Apple Computer, Inc. — (Last Updated 3/8/2000)